<?php
/**
 * 
 * 
 * $Rev: 4 $
 * $Author: thejahweh $
 * $Date: 2010-07-02 07:34:59 +0000 (Fri, 02 Jul 2010) $
 * $Id: pdo.php 4 2010-07-02 07:34:59Z thejahweh $
 * $URL: http://allone.googlecode.com/svn/trunk/plugins/pdo/pdo.php $
 * @author: Adrian Liechti <info@jahweh.ch>
 * @copyright: 2010 Adrian Liechti, GPL3 and CC3 BY-SA
 */

defined('OUTPUT') or die();
global $db;

if (isset($t->cfg->login) === false) {
	$cm = $t->cfg->addChild('login');
	$cm->addAttribute('type','mysql');
	$cm->addAttribute('host','localhost');
	$cm->addAttribute('name','allone');
	$cm->addAttribute('user','root');
	$cm->addAttribute('pass','');
	$t->cfg->save();
}

$dbtype = $t->cfg->login['type'];
$dbhost = $t->cfg->login['host'];
$dbname = $t->cfg->login['name'];
$dbuser = $t->cfg->login['user'];
$dbpass = $t->cfg->login['pass'];

$dsn = "$dbtype:dbname=$dbname;host=$dbhost";


try {
    $db = new PDO($dsn, $dbuser, $dbpass);
} catch (PDOException $e) {
	die('Connection failed: ' . $e->getMessage());
}

$db->query("SET NAMES 'utf8';");


?>